package river_city_ransom.implementations;

import exceptions.ComposantError;
import river_city_ransom.services.Bloc;
import river_city_ransom.services.Position;
import river_city_ransom.types.BlocType;
import tools.Toolbox;


public class Bloc_I implements Bloc {
	private BlocType type;
	private Position position;

	public Bloc_I(BlocType bt, Position p) {
		super();
		try {
			init(bt, p);
		}
		catch(ComposantError e) {
			System.err.println(e.getMessage());
		}
	}
	
	@Override
	public boolean equals(Object o) {
		if(!(o instanceof Bloc)) {
			return false;
		}
		if(type() != ((Bloc) o).type()) {
			return false;
		}
		if(!Toolbox.equals(position(), ((Bloc) o).position())) {
			return false;
		}
		return true;
	}

	/** ________________________________________________________ CONSTRUCTORS */
	@Override
	public void init(BlocType bt, Position p) throws ComposantError {
		this.type = bt;
		this.position = p;
	}

	/** _________________________________________________________ OBSERVATORS */
	@Override
	public BlocType type() {
		return type;
	}

	@Override
	public Position position() {
		return position;
	}
}
